package com.nuoniu.sibanyun.service.crm.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.nuoniu.sibanyun.entity.crm.CrmShareConfig;
import com.nuoniu.sibanyun.entity.crm.CrmWebConfig;
import com.nuoniu.sibanyun.entity.crm.CrmWebImg;
import com.nuoniu.sibanyun.mapper.crm.CrmWebConfigMapper;
import com.nuoniu.sibanyun.service.crm.ICrmShareConfigService;
import com.nuoniu.sibanyun.service.crm.ICrmWebConfigService;
import com.nuoniu.sibanyun.service.crm.ICrmWebImgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
 * <p>
 * 网站配置 服务实现类
 * </p>
 *
 * @author baiqiang
 * @since 2020-07-25
 */
@Service
public class CrmWebConfigServiceImpl extends ServiceImpl<CrmWebConfigMapper, CrmWebConfig> implements ICrmWebConfigService {


    @Autowired
    private ICrmWebImgService crmWebImgService;
    @Autowired
    private ICrmShareConfigService shareConfigService;

    @Override
    public HashMap<String, Object> getLoginConfig(Integer shareId) {
        HashMap<String, Object> loginConfig = baseMapper.getLoginConfig();
        List<CrmWebImg> loginImages = crmWebImgService.loginImg();
        loginConfig.put("loginImages",loginImages);
        if(shareId != null) {
            CrmShareConfig shareConfig = shareConfigService.getById(shareId);
            loginConfig.put("shareContent", shareConfig.getShareContent());
            loginConfig.put("shareRemark", shareConfig.getShareRemark());
        }
        return loginConfig;
    }
}
